home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Thread Manager / Thread Manager 2.1.1d1+ / ThreadedSort / Sprocket / Interfaces / Window.h < prev   
Encoding:
C/C++ Source or Header  |  1995-04-28  |  4.0 KB  |  148 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Window.h
  3.  
  4.     Contains:    Definition of TWindow, a base class which provides a
  5.                 framework for building way-cool windows which even John
  6.                 Sullivan would be happy with. Floating windows and “smart
  7.                 zooming” algorithms are based on code samples provided by
  8.                 Dean Yu.
  9.                 
  10.     Written by: Dave Falkenburg, Dean Yu
  11.  
  12.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  13.  
  14.     Change History (most recent first):
  15.      
  16.          <4>    11/12/94    DRF        Added AdjustMenusBeforeMenuSelection.
  17.          <3>     11/8/94    DRF        Add some better menu handling methods.
  18.          <2>      9/4/94    DRF        Added DrawJustTheGrowIcon.
  19.  */
  20.  
  21. #ifndef        _WINDOW_
  22. #define        _WINDOW_
  23.  
  24. #ifndef        __TYPES__
  25. #include    <Types.h>
  26. #endif
  27.  
  28. #ifndef        __WINDOWS__
  29. #include    <Windows.h>
  30. #endif
  31.  
  32. #ifndef        __EVENTS__
  33. #include    <Events.h>
  34. #endif
  35.  
  36. #ifndef        __DRAG__
  37. #include    <Drag.h>
  38. #endif
  39.  
  40. typedef    short    WindowTemplateID;
  41.  
  42.  
  43. class    TWindow
  44.     {
  45. public:
  46.     enum WindowType
  47.         {
  48.         kNormalWindow = 0,
  49.         kFloatingWindow,
  50.         kModalWindow
  51.         };
  52.  
  53.                         TWindow();
  54.     virtual                ~TWindow();
  55.  
  56.     //    Event routing methods
  57.  
  58.     virtual    Boolean        EventFilter(EventRecord * theEvent);    
  59.  
  60.     //    Methods you shouldn’t need to override, but might need to
  61.  
  62.     virtual void        CreateWindow(WindowType typeOfWindowToCreate = kNormalWindow);
  63.     virtual    void        Select(void);
  64.     virtual    void        Drag(Point startPoint);
  65.     virtual void        Nudge(short horizontalDistance, short verticalDistance);
  66.     virtual void        Grow(Point startPoint);
  67.     virtual void        Zoom(short zoomState);
  68.  
  69.     virtual    void        ShowHide(Boolean showFlag);
  70.  
  71.     //    Methods which MUST be overridden:
  72.  
  73.     virtual WindowPtr    MakeNewWindow(WindowPtr behindWindow)    = 0;
  74.     
  75.  
  76.     //    Methods which probably should be overridden
  77.  
  78.     virtual    void        AdjustCursor(EventRecord * anEvent);
  79.     virtual void        Idle(EventRecord * anEvent);
  80.     virtual void        Activate(Boolean activating);
  81.     virtual void        Draw(void);
  82.     virtual void        Click(EventRecord * anEvent);
  83.     virtual    void        KeyDown(EventRecord * anEvent);
  84.  
  85.     virtual void        GetPerfectWindowSize(Rect * perfectSize);
  86.     virtual    void        GetWindowSizeLimits(Rect * limits);
  87.     virtual void        AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
  88.  
  89.  
  90.     //    Window property accessor methods…
  91.     //        …watch for new ones when we add scripting support    
  92.     
  93.     virtual    Boolean        IsVisible(void);
  94.     
  95.     virtual    Boolean        CanClose(void);        
  96.     virtual    Boolean        Close(void);
  97.     virtual    Boolean        DeleteAfterClose(void);
  98.     
  99.     //    Methods for handling menus & menu commands
  100.     
  101.     virtual    void        AdjustMenusBeforeMenuSelection(void);
  102.     virtual void        DoMenuSelection(short menu, short item);
  103.     virtual void        DoMenuCommand(unsigned long menuCommand);
  104.  
  105.     //    Methods for use with the Drag Manager
  106.     
  107.     virtual    OSErr        HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
  108.  
  109.     virtual    OSErr        DragEnterWindow(DragReference theDrag);
  110.     virtual    OSErr        DragInWindow(DragReference theDrag);
  111.     virtual    OSErr        DragLeaveWindow(DragReference theDrag);
  112.  
  113.     virtual    OSErr        HandleDrop(DragReference theDragRef);
  114.  
  115.  
  116. protected:
  117.     WindowPtr            fWindow;
  118.     WindowType            fWindowType;
  119.  
  120.     Boolean                fIsVisible;
  121.     };
  122.  
  123.  
  124. //    Utility Functions:
  125.  
  126. //    Don’t you just wish you didn’t have to do this?
  127. pascal WindowPtr    GetNewColorOrBlackAndWhiteWindow(short windowID, void *wStorage, WindowPtr behind);
  128. pascal WindowPtr    NewColorOrBlackAndWhiteWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon);
  129.  
  130. void                DrawJustTheGrowIcon(WindowPtr theWindow);
  131.  
  132. TWindow *            GetWindowObject(WindowPtr aWindow);
  133.  
  134. WindowPtr            FrontModalWindow(void);
  135. WindowPtr            LastModalWindow(void);
  136. WindowPtr            FrontFloatingWindow(void);
  137. WindowPtr            LastFloatingWindow(void);
  138. WindowPtr            FrontNonFloatingWindow(void);
  139.  
  140. void                HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
  141. void                SuspendResumeWindows(Boolean resuming);
  142. void                HiliteWindowsForModalDialog(Boolean hiliting);
  143.  
  144. pascal OSErr        CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow,void *handlerRefCon,DragReference theDragRef);
  145. pascal OSErr        CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,DragReference theDragRef);
  146.  
  147. #endif
  148.